package com.example;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Activity_LV extends ListActivity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        List<HashMap<String,String>> listMap = new ArrayList<HashMap<String, String>>();
        HashMap<String,String> map1 = new HashMap<String, String>();
        HashMap<String,String> map2 = new HashMap<String, String>();
        HashMap<String,String> map3 = new HashMap<String, String>();

        map1.put("userName","张山峰");
        map1.put("userIp","192.168.1.10") ;
        map2.put("userName","黄无良");
        map2.put("userIp","192.168.1.13") ;
        map3.put("userName","李贱种");
        map3.put("userIp","192.168.1.60") ;

        listMap.add(map1);
        listMap.add(map2);
        listMap.add(map3);

        SimpleAdapter simpleAdapter = new SimpleAdapter(this,listMap,R.layout.user,new String[]{"userName","userIp"},new int[]{R.id.userName,R.id.userIp});
        setListAdapter(simpleAdapter);

    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {

        super.onListItemClick(l,v,position,id);

        System.out.println("id--------------------" + id);
        System.out.println("position--------------" + position);


    }
}
